<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/common/html/head :: head_Normal(~{::title},~{::link},~{::style})">
    <title th:text=${title}></title>
    <link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
    <style type="text/css">
        .select-list ul li{
            list-style-type: none;
            float: left;
        }
    </style>

</head>

<body id="listbody">
<!-- 右边内容 -->
<div class="wrap-fluid">

    <div class="container-fluid bevel tlbr" style="min-height: 600px;position: relative;overflow: hidden;">
        <div class="body-nest" id="search_div"  style="display: block">
            <div class="form_left">
                <form role="form" class="form-inline">
                    <button onclick="save()" class="btn btn-success" type="button" style="margin-left: 90%"><i class="fa fa-edit"></i>&nbsp;保存</button>
                </form>
            </div>
        </div>
        <div class="" style="font-size: 16px;padding-top: 12px;height: 1px;">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            name-缓存名,&nbsp;&nbsp; duration-缓存时间(秒), &nbsp;&nbsp;size-缓存大小
        </div>
        <div class="nest" id="Blank_PageClose" style="height: 1000px;">
            <div class="title-alt" style="height: 1px;">

            </div>
            <div class="body-nest" id="Blank_Page_Content" style="height: 1000px;">
                <iframe  width="100%"  height="90%"  id="json" name="json"  src="/cache/viewDetail" frameborder="0" marginheight="0" marginwidth="0" border="false"></iframe>
            </div>
        </div>
    </div>
</div>
<!-- 结束右边内容 -->

<!-- 通用js -->
<div th:include="admin/common/html/js :: onload_js">

</div>
<script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>
<script th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>

<script th:inline="javascript">
    var rules = [[${rules}]];
    var initApp = 1;
    if(rules != null){
         initApp = rules.app;
    }

</script>

<script type="text/javascript">
    function save(){
        var app = $("#apps", parent.document.body).val();
        var keyCache =  window.frames["json"].document.getElementById("myWord").value;
        var cacheRuleJson = JSON.parse(keyCache);
        for(var k in cacheRuleJson){
        	var cacheRule = cacheRuleJson[k];
        	if(cacheRule.hasOwnProperty("size")){
        		var size = cacheRule.size;
        		if(Number(size) > 100000){
        			if(confirm("缓存设置过大可能导致GC问题，确实要设置吗？")){
        				break;
        			} else {
        				return;
        			}
        		}
        	}
        }
        var target =  window.frames["json"].document.getElementById("json-target").innerText;

        if(target.indexOf("解析错误") != -1 ){
            $.modal.alertError("非法的json数组");
            return false;
        }
        $.ajax({
            cache : true,
            type : "POST",
            url : "/cache/save",
            data:{"app":app, "keyCache": keyCache},
            async : false,
            error : function(XMLHttpRequest){
                $.modal.alertError(XMLHttpRequest.responseJSON.msg);
            },
            success : function(data) {
                $.operate.saveSuccess(data);
            }
        });
    }
</script>

</body>

</html>
